home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1997 / HAM Radio 1997.iso / vcls / wsanet8a / wsanet / wfinger / vb20 / wfinger.frm < prev    next >
Text File  |  1996-04-08  |  6KB  |  213 lines

  1. VERSION 2.00
  2. Begin Form Main 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "WFinger - Test of WSNetC"
  5.    Height          =   5865
  6.    Icon            =   WFINGER.FRX:0000
  7.    Left            =   930
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   5490
  10.    ScaleWidth      =   6930
  11.    Top             =   1080
  12.    Width           =   7020
  13.    Begin TextBox TextHost 
  14.       FontBold        =   0   'False
  15.       FontItalic      =   0   'False
  16.       FontName        =   "MS Sans Serif"
  17.       FontSize        =   8.25
  18.       FontStrikethru  =   0   'False
  19.       FontUnderline   =   0   'False
  20.       Height          =   285
  21.       Left            =   1800
  22.       TabIndex        =   4
  23.       Text            =   "rhino.ess.harris.com"
  24.       Top             =   495
  25.       Width           =   5010
  26.    End
  27.    Begin TextBox TextUsername 
  28.       FontBold        =   0   'False
  29.       FontItalic      =   0   'False
  30.       FontName        =   "MS Sans Serif"
  31.       FontSize        =   8.25
  32.       FontStrikethru  =   0   'False
  33.       FontUnderline   =   0   'False
  34.       Height          =   285
  35.       Left            =   180
  36.       TabIndex        =   2
  37.       Text            =   "iblenke"
  38.       Top             =   495
  39.       Width           =   1185
  40.    End
  41.    Begin CommandButton BtnFinger 
  42.       Caption         =   "&Finger"
  43.       Height          =   375
  44.       Left            =   165
  45.       TabIndex        =   1
  46.       Top             =   840
  47.       Width           =   1200
  48.    End
  49.    Begin NetClient NetClient 
  50.       Left            =   6420
  51.       LineDelimiter   =   ""
  52.       RecvSize        =   4096
  53.       RecvThreshold   =   0
  54.       Top             =   1380
  55.    End
  56.    Begin TextBox TextDisplay 
  57.       Height          =   4095
  58.       Left            =   0
  59.       MultiLine       =   -1  'True
  60.       ScrollBars      =   2  'Vertical
  61.       TabIndex        =   0
  62.       Text            =   "Empty."
  63.       Top             =   1320
  64.       Width           =   6375
  65.    End
  66.    Begin Label LabelHost 
  67.       Alignment       =   2  'Center
  68.       BackColor       =   &H00C0C0C0&
  69.       BackStyle       =   0  'Transparent
  70.       Caption         =   "LabelHost"
  71.       FontBold        =   -1  'True
  72.       FontItalic      =   0   'False
  73.       FontName        =   "MS Sans Serif"
  74.       FontSize        =   12
  75.       FontStrikethru  =   0   'False
  76.       FontUnderline   =   0   'False
  77.       Height          =   390
  78.       Left            =   60
  79.       TabIndex        =   6
  80.       Top             =   0
  81.       Width           =   6780
  82.    End
  83.    Begin Label LabelErrors 
  84.       BackColor       =   &H00C0C0C0&
  85.       BackStyle       =   0  'Transparent
  86.       Caption         =   "No Errors."
  87.       Height          =   375
  88.       Left            =   1815
  89.       TabIndex        =   5
  90.       Top             =   855
  91.       Width           =   4935
  92.    End
  93.    Begin Label Label1 
  94.       BackColor       =   &H00C0C0C0&
  95.       Caption         =   "@"
  96.       FontBold        =   -1  'True
  97.       FontItalic      =   0   'False
  98.       FontName        =   "MS Sans Serif"
  99.       FontSize        =   9.75
  100.       FontStrikethru  =   0   'False
  101.       FontUnderline   =   0   'False
  102.       Height          =   255
  103.       Left            =   1440
  104.       TabIndex        =   3
  105.       Top             =   510
  106.       Width           =   255
  107.    End
  108. End
  109. Dim CRLF As String
  110.  
  111. Sub BtnFinger_Click ()
  112.  
  113.     On Error Resume Next
  114.  
  115.     LabelErrors.Caption = "No Errors."
  116.     
  117.     TextDisplay.Text = ""
  118.  
  119.     ' WSNetC code
  120.     NetClient.HostName = TextHost
  121.     If NetClient.HostName = "" Then
  122.         NetClient.HostAddr = TextHost
  123.         If NetClient.HostName = "" Then
  124.             MsgBox "Sorry, " + TextHost + " could not be resolved.", 48
  125.             Exit Sub
  126.         End If
  127.     End If
  128.     NetClient.Connect = True
  129.     
  130.     ' We are completing a query, ignore user
  131.     TextDisplay.SetFocus
  132.     BtnFinger.Enabled = False
  133.     Main.MousePointer = 11
  134. End Sub
  135.  
  136. Sub Form_Load ()
  137.     CRLF = Chr$(13) + Chr$(10)
  138.  
  139.     LabelHost = NetClient.HostName
  140.  
  141.     ' Use "finger" service (or port 79)
  142.     NetClient.RemoteService = "finger"
  143.     If NetClient.RemotePort = 0 Then
  144.         NetClient.RemotePort = 79
  145.     End If
  146. End Sub
  147.  
  148. Sub Form_Resize ()
  149.     
  150.     If Main.WindowState = 1 Then Exit Sub
  151.  
  152.     TextDisplay.Width = ScaleWidth
  153.     TextDisplay.Height = Abs(ScaleHeight - TextDisplay.Top)
  154.  
  155.     TextHost.Width = Abs(ScaleWidth - TextHost.Left - 120)
  156.     LabelErrors.Width = Abs(ScaleWidth - LabelErrors.Left - 120)
  157.  
  158. End Sub
  159.  
  160. Sub NetClient_OnClose ()
  161.     
  162.     On Error Resume Next
  163.  
  164.     NetClient.Connect = False
  165.  
  166.     LabelErrors.Caption = "Connection closed."
  167.     BtnFinger.Enabled = True
  168.     Main.MousePointer = 0
  169.  
  170. End Sub
  171.  
  172. Sub NetClient_OnConnect ()
  173.     
  174.     On Error Resume Next
  175.     
  176.     LabelErrors.Caption = "Connected to port " + Str$(NetClient.RemotePort)
  177.     NetClient.SendLine = TextUsername.Text + CRLF
  178.  
  179. End Sub
  180.  
  181. Sub NetClient_OnError (iErrorNumber As Integer)
  182. Dim ErrorMessage As String
  183. Dim ErrorNumberText As String
  184.  
  185.     On Error Resume Next
  186.  
  187.     ErrorMessage = NetClient.ErrorMessage
  188.     ErrorNumberText = Str$(iErrorNumber)
  189.  
  190.     LabelErrors.Caption = "Error #" + ErrorNumberText + ": " + ErrorMessage
  191.     
  192.     ' Disconnect for good measure
  193.     NetClient.Connect = False
  194.     BtnFinger.Enabled = True
  195.     Main.MousePointer = 0
  196.  
  197. End Sub
  198.  
  199. Sub NetClient_OnRecv ()
  200. Dim sInput As String
  201.  
  202.     On Error Resume Next
  203.  
  204.     ' Loop until buffer is empty (this doesn't block)
  205.     Do While Not NetClient.RecvCount = 0
  206.         sInput = NetClient.RecvLine
  207.         TextDisplay.Text = TextDisplay.Text + sInput
  208.         DoEvents
  209.     Loop
  210.  
  211. End Sub
  212.  
  213.